/**
 * Copyright (c) 2012 Nokia Corporation.
 * All rights reserved.
 *
 * For the applicable distribution terms see the license text file included in
 * the distribution.
 */

import QtQuick 1.1
import com.nokia.meego 1.0

Page {
    property alias placesMap: placesMap

    /*!
      Opens the details page according to the currently selected landmark.
    */
    function openDetailsPage()
    {
        if (!placesMap.selectedLandmark) {
            console.debug("PlacesMapPage.qml: openDetailsPage(): Error: No landmark selected!");
            return;
        }

        filterBar.hide();
        pageStack.push("qrc:/PlacesDetailPage.qml",
                       { placeId: placesMap.selectedLandmark.description });
    }

    PlacesMap {
        id: placesMap
        anchors.fill: parent
        onBubbleClicked: openDetailsPage();
        onBubbleLongPress: landmarkContextMenu.open();
    }

    Menu {
        id: landmarkContextMenu

        content: MenuLayout {
            MenuItem {
                text: qsTr("Details");
                onClicked: openDetailsPage();
            }
            MenuItem {
                text: qsTr("Route");

                onClicked: {
                    if (placesMap.selectedLandmark) {
                        var coordinate = placesMap.selectedLandmark.coordinate;
                        placesMap.drawRoute(coordinate.latitude,
                                            coordinate.longitude);
                    }
                }
            }
        }
    }
}
